package ph.com.gs3.formalistics.model.vo.business.document;

import java.util.List;

import ph.com.gs3.formalistics.global.constants.StarMark;
import ph.com.gs3.formalistics.global.utilities.DateUtilities;
import ph.com.gs3.formalistics.model.vo.business.form.Form;

public class DocumentHeaderData {

	private String webId;
	private String formWebId;
	private String trackingNumber;

	private String status;

	private String dateCreated;
	private String dateUpdated;

	private List<String> fieldsRequired;
	private List<String> fieldsEnabled;
	private List<String> fieldsHidden;

	private StarMark starMark;

	public static DocumentHeaderData createFromForm(Form form) {

		DocumentHeaderData data = new DocumentHeaderData();

		data.setWebId("0");
		data.setTrackingNumber(null);
		data.setFormWebId(form.getWebId());

		data.setStatus(null);

		data.setDateCreated(DateUtilities.getServerFormattedCurrentDate());
		data.setDateUpdated(DateUtilities.getServerFormattedCurrentDate());

		data.setFieldsRequired(form.getOnCreateFieldsEnabled());
		data.setFieldsEnabled(form.getOnCreateFieldsEnabled());
		data.setFieldsHidden(form.getOnCreateFieldsHidden());

		data.setStarMark(StarMark.UNSTARRED);

		return data;

	}

	public static DocumentHeaderData createFromDocument(Document document, Form form) {

		DocumentHeaderData data = new DocumentHeaderData();

		data.setWebId(document.getWebId());
		data.setTrackingNumber(document.getTrackingNumber());
		data.setFormWebId(form.getWebId());

		data.setStatus(document.getStatus());

		data.setDateCreated(document.getDateCreated());
		data.setDateUpdated(document.getDateUpdated());

		data.setFieldsRequired(document.getFieldsRequired());
		data.setFieldsEnabled(document.getFieldsEnabled());
		data.setFieldsHidden(document.getFieldsHidden());

		data.setStarMark(document.getStarMark());

		return data;

	}

	public static DocumentHeaderData createFromOutgoingAction(OutgoingAction outgoingAction,
	        Form form) {

		Document document = outgoingAction.getDocument();
		DocumentHeaderData data = createFromDocument(document, form);

		data.setStatus("Outgoing Action");

		return data;

	}

	// ==============================================================
	// Getters & Setters

	public String getWebId() {
		return webId;
	}

	public void setWebId(String webId) {
		this.webId = webId;
	}

	public String getFormWebId() {
		return formWebId;
	}

	public void setFormWebId(String formWebId) {
		this.formWebId = formWebId;
	}

	public String getTrackingNumber() {
		return trackingNumber;
	}

	public void setTrackingNumber(String trackingNumber) {
		this.trackingNumber = trackingNumber;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getDateCreated() {
		return dateCreated;
	}

	public void setDateCreated(String dateCreated) {
		this.dateCreated = dateCreated;
	}

	public String getDateUpdated() {
		return dateUpdated;
	}

	public void setDateUpdated(String dateUpdated) {
		this.dateUpdated = dateUpdated;
	}

	public List<String> getFieldsRequired() {
		return fieldsRequired;
	}

	public void setFieldsRequired(List<String> fieldsRequired) {
		this.fieldsRequired = fieldsRequired;
	}

	public List<String> getFieldsEnabled() {
		return fieldsEnabled;
	}

	public void setFieldsEnabled(List<String> fieldsEnabled) {
		this.fieldsEnabled = fieldsEnabled;
	}

	public List<String> getFieldsHidden() {
		return fieldsHidden;
	}

	public void setFieldsHidden(List<String> fieldsHidden) {
		this.fieldsHidden = fieldsHidden;
	}

	public StarMark getStarMark() {
		return starMark;
	}

	public void setStarMark(StarMark starMark) {
		this.starMark = starMark;
	}

	// }}

}
